//
// Created by Castle-Moriarty on 2025/11/4.
//
#include <iostream>
using namespace std;

// 类的定义
class Rectangle {
public:
    // 成员变量
    double length;
    double width;
    // 构造函数，用于初始化对象
    Rectangle(double len, double wid) {
        length = len;
        width = wid;
    }

    double getArea() {
        return length * width;
    }
};

class Student {
public:
    ~Student() {
        cout << "我是析构函数，我被调用了" << endl;
    }
};

int main() {
    Rectangle rect1(5.0, 3.0);
    Rectangle rect2(4.0, 6.0);

    cout << "rect1 area : " << rect1.getArea() << endl;
    cout << "rect2 area : " << rect2.getArea() << endl;


    Student *pmalloc = (Student*)malloc(sizeof(Student));
    free(pmalloc);  // 不会调用析构函数，因此堆空间内存仍不会被释放

    return 0;
}
